﻿using System;
using DDDNorthWind.Core.Domain.ValueObject;

namespace DDDNorthWind.AC.ImportProducts.Domain.ValueObjects
{
    public class ImportProductPrice : ValueObject<ImportProductPrice>
    {
        public decimal SuggestedRetailPrice { get; set; }

        public DateTime? StartDate { get; set; }

        public DateTime? EndDate { get; set; }

        #region "Equals"
        public override bool Equals(object obj)
        {
            return base.Equals(obj);
        }

        public override bool Equals(ImportProductPrice other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return other.SuggestedRetailPrice == SuggestedRetailPrice
                && other.StartDate.Equals(StartDate)
                && other.EndDate.Equals(EndDate);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int result = SuggestedRetailPrice.GetHashCode();
                result = (result * 397) ^ (StartDate.HasValue ? StartDate.Value.GetHashCode() : 0);
                result = (result * 397) ^ (EndDate.HasValue ? EndDate.Value.GetHashCode() : 0);
                return result;
            }
        }

        public static bool operator ==(ImportProductPrice left, ImportProductPrice right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(ImportProductPrice left, ImportProductPrice right)
        {
            return !Equals(left, right);
        } 
        #endregion
    }
}